package main

import "fmt"

var globalVarPtr *int

func function()  {
	var a = 10
	globalVarPtr = &a
}

func function1(value int) int {
	var b = value
	return b
}

func function2(value int)  {
	var b = value
	b++
}

func function3(ptr *int) *int {
	*ptr = 10
	return ptr
}

func function4() *int {
	var m = 10
	return &m
}

/*
go run --gcflags "-m -l" escape.go
*/

func main() {
	fmt.Println("escape analysis ... ... ")
	var d = 10
	c := function1(d)

	function2(c)

	var ptr *int = new(int)
	var ptr2 *int = function3(ptr)
	fmt.Println(*ptr2)

	ptr3 := function4()
	*ptr3++
}
